using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.Serialization.Formatters.Binary;
using System.IO;

namespace AspWebUtilities.Farm
{
	public partial class FarmData
	{
		private static byte[] ToBinary(Object oo)
		{
			MemoryStream fs = new MemoryStream();

			// Construct a BinaryFormatter and use it to serialize the data to the stream.
			if (oo != null)
			{
				BinaryFormatter formatter = new BinaryFormatter();
				formatter.Serialize(fs, oo);
			}
			return fs.ToArray();
		}

		private static Object ToObject(byte[] bytes)
		{
			MemoryStream fs = new MemoryStream(bytes);

			// Construct a BinaryFormatter and use it to serialize the data to the stream.
			BinaryFormatter formatter = new BinaryFormatter();
			return formatter.Deserialize(fs);
		}

		private static ulong ToNumber(byte[] bytes)
		{
			ulong ii = 0;

			foreach (byte bb in bytes)
			{
				ii = ii * 256 +  bb;
			}
			return ii;
		}

	}
}
